import Vue from 'vue'
import VueRouter from 'vue-router'
import homeRouters from './homeRouters'
import newsRouters from './newsRouters'
import solutionRouters from './solutionRouters'
import supplyDemandRouters from './supplyDemandRouters'
import businessPlatformRouters from './businessPlatformRouters'
import partnerRouters from './partnerRouters'
import serviceRouters from './serviceRouters'
import userCenterRouters from './userCenterRouters'
import loginRouters from './loginRouters'

import Dashboard from '@/views/Dashboard/Dashboard'
// import NewsList from '@/views/News/NewsList'
// import NewsDetail from '@/views/News/NewsDetail'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  // {
  //   path: '/news-list',
  //   name:'NewsList',
  //   component : NewsList
  // },
  // {
  //   path: '/news-detail',
  //   name:'NewsDetail',
  //   component : NewsDetail
  // },
  {
    path: '/dashboard',
    name: 'dashboard',
    component: Dashboard,
    children: [
      homeRouters,
      newsRouters,
      ...solutionRouters,
      ...supplyDemandRouters,
      businessPlatformRouters,
      ...partnerRouters,
      serviceRouters,
      userCenterRouters,
      loginRouters
    ]
  }
]

const router = new VueRouter({
  // 解决路由跳转页面没有置顶
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  },
  routes
})

export default router
